package com.fhz.day007;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.fhz.day007.core.BaseViewModel;
import com.fhz.day007.entity.Category;
import com.fhz.utilsfhz.ApiResponse;

import java.util.List;

/**
 * 时间:2022/5/25
 *
 * @author msfeng
 * 简述: TODO
 */
public class MainViewModel extends BaseViewModel<MainRepository> {

    public MainViewModel(MainRepository repository) {
        super(repository);
    }


//    public void getCategory(int i){
//        LiveData<ApiResponse<List<Category>>> categroy = getCategroy(i);
//
//    }

    //用来存放数据的
    private MutableLiveData<ApiResponse<List<Category>>> mutableLiveData = new MutableLiveData<>();
    public MutableLiveData<ApiResponse<List<Category>>> getMutableLiveData() {
        return mutableLiveData;
    }


    public LiveData<ApiResponse<List<Category>>> getCategroy(int page){
        LiveData<ApiResponse<List<Category>>> categroy = repository.getCategroy(page);
//        mutableLiveData.setValue(categroy.getValue());//null指针
        return categroy;
    }
}

